<template>
	<view class="me">
		<view class="head">
			<view class="headImg">
				<view v-if="phone">
						<image :src="avatarUrl" mode="widthFix"></image>
				</view>
				<button v-else class="text" @click="toLogin()">
					请登录
				</button>
			</view>
			<view class="name" v-if="phone">
				<text>{{nickname}}</text>
			</view>
			
		</view>
		<view class="collection" v-if="phone" @click="toCollection()">
			<text class="left">我的收藏</text>
			<view class="right">
				<van-icon name="arrow" color="#ccc" size="22px"/>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				userId:'',
				phone:'',
				avatarUrl:'',
				nickname:''
			}
		},
		onShow() {
			this.getUserInfo();
		},
		methods: {
			onChooseAvatar(e){
				// console.log(e)
				this.avatarUrl=e.detail.avatarUrl;
			},
			getUserInfo(){
						this.userId = uni.getStorageSync('userId')
						this.phone = uni.getStorageSync('phone')
						this.nickname = uni.getStorageSync('nickname')
						this.avatarUrl = uni.getStorageSync('avatarUrl')
			},
			toCollection(){
				uni.navigateTo({
					url: '/pages/me/collection?userId='+this.userId
				});
			},
			toLogin(){
				uni.navigateTo({
					url: '/pages/me/user'
				});
			}
		}
	}
</script>


<style lang="scss">
	@import './style.scss';
</style>
